{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "$\\newcommand{norm}[1]{||#1||}$\n",
    "$\\newcommand{mbx}{\\mathbf x}$\n",
    "$\\newcommand{mbu}{\\mathbf u}$\n",
    "$\\newcommand{d}{\\text{div }}$\n",
    "$\\newcommand{mbf}{\\mathbf f}$\n",
    "$\\newcommand{t}{\\text{tr }}$\n",
    "$\\newcommand{mcA}{\\mathcal A}$\n",
    "$\\newcommand{mbv}{\\mathbf v}$\n",
    "$\\newcommand{mbn}{\\mathbf n}$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 基本概念"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 重力加速度\n",
    "\n",
    "$g = 9.80665m/s^2$ \n",
    "\n",
    "1 千克的物体获得 1 $m/s^2$ 的加速度的力就是 \n",
    "\n",
    "$$\n",
    "1 N = 1 kg\\cdot m/s^2\n",
    "$$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 应力张量 $\\sigma$ (stress)\n",
    "\n",
    "基本单位 $Pa$， $KPa$， $MPa$， \n",
    "每平方米 1 牛的力就是 1 $Pa$， 没有方向， 和压强一样, 求散度之后单位变为\n",
    "\n",
    "$$\n",
    "N/m^3 = kg \\cdot m/s^2/m^3 = kg/(m^2\\cdot s^2)\n",
    "$$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 应变张量 $\\epsilon$ (strain)\n",
    "没有单位， 它是一个长度的变化量和原来长度的比值。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 体力 $\\mbf$ 的单位 \n",
    "\n",
    "$$\n",
    "kg/m^3\\cdot m/s^2 = kg/(m^2\\cdot s^2)\n",
    "$$\n",
    "\n",
    "$$\n",
    "1 t/mm^3 = 1000 kg/(0.001 m)^3 = 1000 kg/(10^{-9}m^3) = 10^{12}kg/m^3\n",
    "$$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "$$\n",
    "1 MPa/mm = 10^6 N/m^2/mm = 10^6 kg\\cdot m/(s^2\\cdot m^2\\cdot mm) = 10^3 t/(s^2\\cdot 10^3 mm^2) = 1 t/(s^2\\cdot mm^2)\n",
    "$$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "$$\n",
    "1 t/mm^3\\cdot mm/s^2 = 1 t/(s^2\\cdot mm^2)\n",
    "$$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 位移 $\\mbu$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "###  拉梅参数 $\\lambda$ 和 $\\mu$ "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "$\\lambda$ 是拉梅第一参数"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "$\\mu$ 是拉梅第二参数，即剪切模量， 有时又记为 $G$，它为剪应力和剪应变之比：\n",
    "\n",
    "$$\n",
    "\\mu \\text{ or } G = \\frac{\\tau}{\\gamma}\n",
    "$$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 杨氏模数或杨氏模量（Young's modulus）"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "它是衡量固体**材料刚性**的一个值， 值越大代表相应固体材料刚性越大。它是线弹性固体材料的力学属性，根据不同的材料或多或少的依赖于温度，这定义了固体材料中应力和应变之间的关系。 \n",
    "\n",
    "正应力和正应变之比：\n",
    "\n",
    "$$\n",
    "E = \\frac{\\sigma}{\\epsilon}\n",
    "$$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 泊松比 $\\nu$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 各个量之间的关系"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "$$\n",
    "\\lambda = \\frac{\\nu E}{(1 + \\nu)(1 - 2\\nu)},\\quad \\mu \\text{ or } G= \\frac{E}{2(1 + \\nu)}\n",
    "$$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 本构关系： 反映物质宏观性质的数学模型"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "** 注: ** 弹性模量共有 6 个参数， 只要知道任意 2 个就可以推出其它 4 个参数。\n",
    "\n",
    "https://zh.wikipedia.org/wiki/%E6%8B%89%E6%A2%85%E5%8F%82%E6%95%B0"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 基本方程"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "静力平衡方程：\n",
    "$$\n",
    "-\\nabla\\cdot \\sigma = \\mbf\n",
    "$$\n",
    "\n",
    "$$\n",
    "\\begin{align}\n",
    "-(\\nabla\\cdot \\sigma, \\mbv) & = (\\mbf, \\mbv) \\\\\n",
    "(\\sigma, \\nabla\\mbv) &= (\\mbf, \\mbv) + <\\sigma\\mbn, \\mbv>\\\\\n",
    "\\end{align}\n",
    "$$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "几何方程：\n",
    "$$\n",
    "\\varepsilon = \\frac{1}{2}(\\nabla \\mbu + \\nabla \\mbu^T) \n",
    "=\n",
    "\\begin{bmatrix}\n",
    "u_x & \\frac{v_x + u_y}{2} & \\frac{w_x + u_z}{2} \\\\\n",
    "\\frac{v_x + u_y}{2} & v_y & \\frac{w_y + v_z}{2} \\\\\n",
    "\\frac{w_x + u_z}{2} & \\frac{w_y + v_z}{2} & w_z \n",
    "\\end{bmatrix}\n",
    "\\rightarrow \n",
    "\\begin{bmatrix}\n",
    "u_x \\\\ w_y \\\\ v_z \\\\ \\frac{w_y + v_z}{2} \\\\ \\frac{w_x + u_z}{2} \\\\ \\frac{v_x + u_y}{2}\n",
    "\\end{bmatrix}\n",
    "$$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "本构方程：\n",
    "\n",
    "$$\n",
    "\\sigma = 2\\mu \\epsilon + \\lambda(\\t \\epsilon) I\n",
    "$$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "$$\n",
    "\\sigma =\n",
    "2\n",
    "\\mu\n",
    "\\begin{bmatrix}\n",
    "u_x & \\frac{v_x + u_y}{2} & \\frac{w_x + u_z}{2} \\\\\n",
    "\\frac{v_x + u_y}{2} & v_y & \\frac{w_y + v_z}{2} \\\\\n",
    "\\frac{w_x + u_z}{2} & \\frac{w_y + v_z}{2} & w_z \n",
    "\\end{bmatrix}\n",
    "+ \n",
    "\\lambda (u_x + v_y + w_z)\n",
    "\\begin{bmatrix}\n",
    "1 & 0 & 0 \\\\\n",
    "0 & 1 & 0 \\\\\n",
    "0 & 0 & 1 \n",
    "\\end{bmatrix}\n",
    "$$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "$$\n",
    "\\begin{align}\n",
    "\\begin{bmatrix}\n",
    "\\sigma_{11} \\\\ \\sigma_{22} \\\\ \\sigma_{33} \\\\ \\sigma_{23} \\\\ \\sigma_{13} \\\\ \\sigma_{12}\n",
    "\\end{bmatrix}\n",
    " & = \n",
    "\\begin{bmatrix}\n",
    "2\\mu u_x + \\lambda (u_x + v_y + w_z)\\\\\n",
    "2\\mu v_y + \\lambda (u_x + v_y + w_z)\\\\\n",
    "2\\mu w_z + \\lambda (u_x + v_y + w_z)\\\\\n",
    "\\mu (w_y + v_z) \\\\\n",
    "\\mu (w_x + u_z) \\\\\n",
    "\\mu (v_x + w_y)\n",
    "\\end{bmatrix}\\\\\n",
    "& = \\begin{bmatrix}\n",
    "2\\mu+\\lambda & \\lambda & \\lambda & 0 & 0 & 0\\\\\n",
    "\\lambda & 2\\mu+\\lambda  & \\lambda & 0 & 0 & 0\\\\\n",
    "\\lambda &  \\lambda & 2\\mu+\\lambda & 0 & 0 & 0 \\\\\n",
    "0 & 0 & 0 & 2\\mu & 0 & 0 \\\\\n",
    "0 & 0 & 0 & 0 & 2\\mu & 0 \\\\\n",
    "0 & 0 & 0 & 0 & 0 & 2\\mu\n",
    "\\end{bmatrix}\n",
    "\\begin{bmatrix}\n",
    "u_x \\\\ v_y \\\\ w_z \\\\ \\frac{w_y + v_z}{2} \\\\ \\frac{w_x + u_z}{2} \\\\ \\frac{v_x + w_y}{2}\n",
    "\\end{bmatrix}\\\\\n",
    "& = \\begin{bmatrix}\n",
    "2\\mu+\\lambda & \\lambda & \\lambda & 0 & 0 & 0\\\\\n",
    "\\lambda & 2\\mu+\\lambda  & \\lambda & 0 & 0 & 0\\\\\n",
    "\\lambda &  \\lambda & 2\\mu+\\lambda & 0 & 0 & 0 \\\\\n",
    "0 & 0 & 0 & \\mu & 0 & 0 \\\\\n",
    "0 & 0 & 0 & 0 & \\mu & 0 \\\\\n",
    "0 & 0 & 0 & 0 & 0 & \\mu\n",
    "\\end{bmatrix}\n",
    "\\begin{bmatrix}\n",
    "\\varepsilon_{11} \\\\ \\varepsilon_{22} \\\\ \\varepsilon_{33} \\\\ 2\\varepsilon_{23} \\\\ 2\\varepsilon_{13} \\\\ 2\\varepsilon_{12}\n",
    "\\end{bmatrix}\\\\\n",
    "&= D \\begin{bmatrix}\n",
    "\\frac{\\partial }{\\partial x} & 0 & 0\\\\\n",
    "0 & \\frac{\\partial }{\\partial y} & 0\\\\\n",
    "0 & 0 & \\frac{\\partial }{\\partial z}\\\\\n",
    "0 & \\frac{\\partial }{\\partial z} & \\frac{\\partial }{\\partial y} \\\\\n",
    "\\frac{\\partial }{\\partial z} & 0 & \\frac{\\partial }{\\partial x} \\\\\n",
    "\\frac{\\partial }{\\partial y} & \\frac{\\partial }{\\partial x} & 0\\\\\n",
    "\\end{bmatrix}\n",
    "\\begin{bmatrix}\n",
    "u \\\\ v\\\\ w\n",
    "\\end{bmatrix}\\\\\n",
    "& = D[\\partial] \n",
    "\\begin{bmatrix}\n",
    "\\lambda_1 & 0 & 0 & \\lambda_2 & 0 & 0 & \\lambda_3 & 0 & 0 & \\lambda_4 & 0 & 0 \\\\\n",
    "0 &\\lambda_1 & 0 & 0 & \\lambda_2 & 0 & 0 & \\lambda_3 & 0 & 0 & \\lambda_4 & 0 \\\\\n",
    "0 & 0 & \\lambda_1 & 0 & 0 & \\lambda_2 & 0 & 0 & \\lambda_3 & 0 & 0 & \\lambda_4\n",
    "\\end{bmatrix}\n",
    "\\begin{bmatrix}\n",
    "\\mbu_1 \\\\ \\mbu_2 \\\\ \\mbu_3 \\\\ \\mbu_4\n",
    "\\end{bmatrix}\\\\\n",
    "& = D\n",
    "\\begin{bmatrix}\n",
    "[\\partial]\\lambda_1, [\\partial]\\lambda_2, [\\partial]\\lambda_3, [\\partial]\\lambda_4]\n",
    "\\end{bmatrix}\n",
    "\\begin{bmatrix}\n",
    "\\mbu_1 \\\\ \\mbu_2 \\\\ \\mbu_3 \\\\ \\mbu_4\n",
    "\\end{bmatrix}\\\\\n",
    "\\end{align}\n",
    "$$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "其中：\n",
    "\n",
    "\\begin{array}{l} \n",
    " G = \\frac{E}{{2\\left( {1 + \\nu } \\right)}} \\\\  \n",
    " A = E\\frac{{\\left( {1 - \\nu } \\right)}}{{\\left( {1 + \\nu } \\right)\\left( {1 - 2\\nu } \\right)}} \\\\  \n",
    " B = \\frac{\\nu }{{\\left( {1 - v} \\right)}} \\\\  \n",
    "\\end{array}\n",
    "\n",
    "$$\n",
    "D = A\\left[ {\\begin{array}{*{20}{c}} \n",
    "   1 & B & B & 0 & 0 & 0  \\\\ \n",
    "   B & 1 & B & 0 & 0 & 0  \\\\ \n",
    "   B & B & 1 & 0 & 0 & 0  \\\\ \n",
    "   0 & 0 & 0 & {\\frac{G}{A}} & 0 & 0  \\\\ \n",
    "   0 & 0 & 0 & 0 & {\\frac{G}{A}} & 0  \\\\ \n",
    "   0 & 0 & 0 & 0 & 0 & {\\frac{G}{A}}  \\\\ \n",
    "\\end{array}} \\right]\n",
    "$$\n",
    "\n",
    "$$\n",
    "\\lambda = \\frac{\\nu E}{(1 + \\nu)(1 - 2\\nu)},\\quad \\mu \\text{ or } G= \\frac{E}{2(1 + \\nu)}\n",
    "$$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "如何表达刚度矩阵？"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "运动平衡方程：\n",
    "$$\n",
    "\\rho\\frac{\\partial^2 \\mbu}{\\partial t^2} - \\nabla\\cdot \\sigma = \\mbf\n",
    "$$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 边界条件"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "面力边界条件：\n",
    "\n",
    "$$\n",
    "\\sigma n_S = F_S\n",
    "$$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "位移边界条件：\n",
    "$$\n",
    "\\mbu = \\mbu_S\n",
    "$$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "混合边界条件："
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##  振动模态分析"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "$$\n",
    "\\rho\\frac{\\partial^2 \\mbu}{\\partial t^2} -\\mu\\Delta\\mbu - (\\lambda+\\mu)\\nabla\\d\\mbu = \\mbf\n",
    "$$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "弱形式：\n",
    "\n",
    "$ \\mbu = \\sum_{i}\\mbu_i\\Phi_i$\n",
    "\n",
    "$$\n",
    "\\begin{align}\n",
    "\\rho (\\frac{\\partial^2 \\mbu}{\\partial t^2}, \\mbv) -(\\mu\\Delta \\mbu, \\mbv) - (\\lambda + \\mu)(\\nabla\\d\\mbu, \\mbv) = (\\mbf, \\mbv)\\\\\n",
    "(\\mu\\nabla\\mbu, \\nabla \\mbv) + (\\nabla\\mbu\\cdot n, \\mbv)_{\\partial\\Omega}\n",
    "\\end{align}\n",
    "$$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 基本问题"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "* 线弹性问题\n",
    "* 体力 $\\mbf$ 是什么？\n",
    "* 四面体的线性元求解\n",
    "* 刚度矩阵 \n",
    "* 质量矩阵\n",
    "* 模态矩阵\n",
    "* "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 线性有限元求解线弹性问题算法流程"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "$$\n",
    "-\\mu\\Delta\\mbu - (\\lambda+\\mu)\\nabla\\d\\mbu = \\mbf\n",
    "$$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "$$\n",
    "-(\\mu\\Delta\\mbu, \\mbv) - (\\lambda + \\mu)(\\nabla \\d\\mbu, \\mbv) = (\\mbf, \\mbv)\n",
    "$$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "$$\n",
    "\\mu(\\nabla \\mbu, \\nabla\\mbv) - \\mu<\\nabla\\mbu\\cdot\\mbn, \\mbv>  + (\\lambda + \\mu)(\\d \\mbu, \\d \\mbv) - (\\lambda + \\mu)<\\d\\mbu, \\mbv\\cdot\\mbn> = (\\mbf, \\mbv)\n",
    "$$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "$$\n",
    "\\mu(\\nabla \\mbu, \\nabla\\mbv)  + (\\lambda + \\mu)(\\d \\mbu, \\d \\mbv) = (\\mbf, \\mbv) + \\mu<\\nabla\\mbu\\cdot\\mbn, \\mbv>  + (\\lambda + \\mu)<\\d\\mbu, \\mbv\\cdot\\mbn> \n",
    "$$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "$$\n",
    "\\mu\n",
    "\\begin{bmatrix}\n",
    "\\nabla\\lambda_1^T\\nabla\\lambda_1 & 0 & 0 &  \\nabla\\lambda_1^T\\nabla\\lambda_2 & 0 & 0 &  \\nabla\\lambda_1^T\\nabla\\lambda_3 & 0 & 0 &  \\nabla\\lambda_1^T\\nabla\\lambda_4 & 0 & 0 \\\\\n",
    "0 & \\nabla\\lambda_1^T\\nabla\\lambda_1 & 0 &  0 & \\nabla\\lambda_1^T\\nabla\\lambda_2 & 0  &  0 & \\nabla\\lambda_1^T\\nabla\\lambda_3 & 0 &  0 & \\nabla\\lambda_1^T\\nabla\\lambda_4 & 0 \\\\\n",
    "0 & 0 & \\nabla\\lambda_1^T\\nabla\\lambda_1 & 0 &  0 & \\nabla\\lambda_1^T\\nabla\\lambda_2 & 0  &  0 & \\nabla\\lambda_1^T\\nabla\\lambda_3 & 0 &  0 & \\nabla\\lambda_1^T\\nabla\\lambda_4\\\\\n",
    "\\nabla\\lambda_2^T\\nabla\\lambda_1 & 0 & 0 &  \\nabla\\lambda_2^T\\nabla\\lambda_2 & 0 & 0 &  \\nabla\\lambda_2^T\\nabla\\lambda_3 & 0 & 0 &  \\nabla\\lambda_2^T\\nabla\\lambda_4 & 0 & 0 \\\\\n",
    "0 & \\nabla\\lambda_2^T\\nabla\\lambda_1 & 0 &  0 & \\nabla\\lambda_2^T\\nabla\\lambda_2 & 0  &  0 & \\nabla\\lambda_2^T\\nabla\\lambda_3 & 0 &  0 & \\nabla\\lambda_2^T\\nabla\\lambda_4 & 0 \\\\\n",
    "0 & 0 & \\nabla\\lambda_2^T\\nabla\\lambda_1 & 0 &  0 & \\nabla\\lambda_2^T\\nabla\\lambda_2 & 0  &  0 & \\nabla\\lambda_2^T\\nabla\\lambda_3 & 0 &  0 & \\nabla\\lambda_2^T\\nabla\\lambda_4\\\\\n",
    "\\nabla\\lambda_3^T\\nabla\\lambda_1 & 0 & 0 &  \\nabla\\lambda_3^T\\nabla\\lambda_2 & 0 & 0 &  \\nabla\\lambda_3^T\\nabla\\lambda_3 & 0 & 0 &  \\nabla\\lambda_3^T\\nabla\\lambda_4 & 0 & 0 \\\\\n",
    "0 & \\nabla\\lambda_2^T\\nabla\\lambda_1 & 0 &  0 & \\nabla\\lambda_3^T\\nabla\\lambda_2 & 0  &  0 & \\nabla\\lambda_3^T\\nabla\\lambda_3 & 0 &  0 & \\nabla\\lambda_3^T\\nabla\\lambda_4 & 0 \\\\\n",
    "0 & 0 & \\nabla\\lambda_3^T\\nabla\\lambda_1 & 0 &  0 & \\nabla\\lambda_3^T\\nabla\\lambda_2 & 0  &  0 & \\nabla\\lambda_3^T\\nabla\\lambda_3 & 0 &  0 & \\nabla\\lambda_3^T\\nabla\\lambda_4\\\\\n",
    "\\nabla\\lambda_4^T\\nabla\\lambda_1 & 0 & 0 &  \\nabla\\lambda_4^T\\nabla\\lambda_2 & 0 & 0 &  \\nabla\\lambda_4^T\\nabla\\lambda_3 & 0 & 0 &  \\nabla\\lambda_4^T\\nabla\\lambda_4 & 0 & 0 \\\\\n",
    "0 & \\nabla\\lambda_4^T\\nabla\\lambda_1 & 0 &  0 & \\nabla\\lambda_4^T\\nabla\\lambda_2 & 0  &  0 & \\nabla\\lambda_4^T\\nabla\\lambda_3 & 0 &  0 & \\nabla\\lambda_4^T\\nabla\\lambda_4 & 0 \\\\\n",
    "0 & 0 & \\nabla\\lambda_4^T\\nabla\\lambda_1 & 0 &  0 & \\nabla\\lambda_4^T\\nabla\\lambda_2 & 0  &  0 & \\nabla\\lambda_4^T\\nabla\\lambda_3 & 0 &  0 & \\nabla\\lambda_4^T\\nabla\\lambda_4\\\\\n",
    "\\end{bmatrix}\n",
    "$$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "$$\n",
    "\\begin{align}\n",
    "(\\lambda+\\mu)\n",
    "\\begin{bmatrix}\n",
    "\\nabla\\lambda_1 \\\\ \\nabla\\lambda_2 \\\\ \\nabla\\lambda_3 \\\\ \\nabla\\lambda_4\n",
    "\\end{bmatrix}\n",
    "\\begin{bmatrix}\n",
    "\\nabla\\lambda_1^T, \\nabla\\lambda_2^T, \\nabla\\lambda_3^T, \\nabla\\lambda_4^T\n",
    "\\end{bmatrix}\n",
    " =(\\lambda+\\mu)\\begin{bmatrix}\n",
    "\\nabla\\lambda_1\\nabla\\lambda_1^T & \\nabla\\lambda_1\\nabla\\lambda_2^T& \\nabla\\lambda_1\\nabla\\lambda_3^T & \\nabla\\lambda_1\\nabla\\lambda_4^T\\\\\n",
    "\\nabla\\lambda_2\\nabla\\lambda_1^T & \\nabla\\lambda_2\\nabla\\lambda_2^T& \\nabla\\lambda_2\\nabla\\lambda_3^T & \\nabla\\lambda_2\\nabla\\lambda_4^T\\\\\n",
    "\\nabla\\lambda_3\\nabla\\lambda_1^T & \\nabla\\lambda_3\\nabla\\lambda_2^T& \\nabla\\lambda_3\\nabla\\lambda_3^T & \\nabla\\lambda_3\\nabla\\lambda_4^T\\\\\n",
    "\\nabla\\lambda_4\\nabla\\lambda_1^T & \\nabla\\lambda_4\\nabla\\lambda_2^T& \\nabla\\lambda_4\\nabla\\lambda_3^T & \\nabla\\lambda_4\\nabla\\lambda_4^T\\\\\n",
    "\\end{bmatrix}\n",
    "\\end{align}\n",
    "$$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "$$\n",
    "\\begin{align}\n",
    "A_{ij} &= \n",
    "\\mu\\begin{bmatrix}\n",
    "\\nabla\\lambda_i^T\\nabla\\lambda_j & 0 & 0 \\\\\n",
    "0 & \\nabla\\lambda_i^T\\nabla\\lambda_j & 0 \\\\\n",
    "0 & 0 & \\nabla\\lambda_i^T\\nabla\\lambda_j\n",
    "\\end{bmatrix}\n",
    "+(\\lambda + \\mu) \\nabla\\lambda_i\\nabla\\lambda_j^T\\\\\n",
    "& = \\begin{bmatrix}\n",
    "(2\\mu + \\lambda)\\lambda_{i,x}\\lambda_{j,x}+\\mu\\lambda_{i,y}\\lambda_{j, y}+\\mu\\lambda_{i,z}\\lambda_{j, z} & (\\lambda + \\mu)\\lambda_{i,x}\\lambda_{j, y} & (\\lambda + \\mu)\\lambda_{i, x}\\lambda_{j, z}\\\\\n",
    "(\\lambda + \\mu)\\lambda_{i,y}\\lambda_{j, x} & \\mu\\lambda_{i,x}\\lambda_{j,x}+(2\\mu + \\lambda)\\lambda_{i,y}\\lambda_{j, y}+\\mu\\lambda_{i,z}\\lambda_{j, z} &  (\\lambda + \\mu)\\lambda_{i, y}\\lambda_{j, z}\\\\\n",
    "(\\lambda + \\mu)\\lambda_{i,z}\\lambda_{j, x} & (\\lambda + \\mu)\\lambda_{i, z}\\lambda_{j, y} & \\mu\\lambda_{i,x}\\lambda_{j,x}+\\mu\\lambda_{i,y}\\lambda_{j, y}+(2\\mu + \\lambda)\\lambda_{i,z}\\lambda_{j, z}\\\\\n",
    "\\end{bmatrix}\\\\\n",
    "& = ([\\partial]\\lambda_i)^T D ([\\partial]\\lambda_j)\\\\\n",
    "& =？\\text{ what is wrong? } \\begin{bmatrix}\n",
    "\\frac{\\partial \\lambda_i}{\\partial x} & 0 & 0 & 0 & \\frac{\\partial \\lambda_i}{\\partial z} & \\frac{\\partial \\lambda_i}{\\partial y}\\\\\n",
    "0 & \\frac{\\partial \\lambda_i }{\\partial y} & 0 & \\frac{\\partial \\lambda_i}{\\partial z} & 0 & \\frac{\\partial \\lambda_i}{\\partial x}\\\\\n",
    "0 & 0 & \\frac{\\partial \\lambda_i}{\\partial z} & \\frac{\\partial \\lambda_i}{\\partial y} & \\frac{\\partial \\lambda_i}{\\partial x} & 0\n",
    "\\end{bmatrix}\n",
    "\\begin{bmatrix}\n",
    "2\\mu+\\lambda & \\lambda & \\lambda & 0 & 0 & 0\\\\\n",
    "\\lambda & 2\\mu+\\lambda  & \\lambda & 0 & 0 & 0\\\\\n",
    "\\lambda &  \\lambda & 2\\mu+\\lambda & 0 & 0 & 0 \\\\\n",
    "0 & 0 & 0 & \\mu & 0 & 0 \\\\\n",
    "0 & 0 & 0 & 0 & \\mu & 0 \\\\\n",
    "0 & 0 & 0 & 0 & 0 & \\mu\n",
    "\\end{bmatrix}\n",
    "\\begin{bmatrix}\n",
    "\\frac{\\partial \\lambda_j}{\\partial x} & 0 & 0\\\\\n",
    "0 & \\frac{\\partial \\lambda_j }{\\partial y} & 0\\\\\n",
    "0 & 0 & \\frac{\\partial \\lambda_j}{\\partial z}\\\\\n",
    "0 & \\frac{\\partial \\lambda_j}{\\partial z} & \\frac{\\partial \\lambda_j}{\\partial y} \\\\\n",
    "\\frac{\\partial \\lambda_j}{\\partial z} & 0 & \\frac{\\partial \\lambda_j}{\\partial x} \\\\\n",
    "\\frac{\\partial \\lambda_j}{\\partial y} & \\frac{\\partial \\lambda_j}{\\partial x} & 0\\\\\n",
    "\\end{bmatrix}\n",
    "\\end{align}\n",
    "$$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "$$\n",
    "\\begin{align}\n",
    "\\begin{bmatrix}\n",
    "\\sigma_{11} \\\\ \\sigma_{22} \\\\ \\sigma_{33} \\\\ \\sigma_{23} \\\\ \\sigma_{13} \\\\ \\sigma_{12}\n",
    "\\end{bmatrix}\n",
    " & = \n",
    "\\begin{bmatrix}\n",
    "2\\mu u_x + \\lambda (u_x + v_y + w_z)\\\\\n",
    "2\\mu v_y + \\lambda (u_x + v_y + w_z)\\\\\n",
    "2\\mu w_z + \\lambda (u_x + v_y + w_z)\\\\\n",
    "\\mu (w_y + v_z) \\\\\n",
    "\\mu (w_x + u_z) \\\\\n",
    "\\mu (v_x + w_y)\n",
    "\\end{bmatrix}\\\\\n",
    "& = \\begin{bmatrix}\n",
    "2\\mu+\\lambda & \\lambda & \\lambda & 0 & 0 & 0\\\\\n",
    "\\lambda & 2\\mu+\\lambda  & \\lambda & 0 & 0 & 0\\\\\n",
    "\\lambda &  \\lambda & 2\\mu+\\lambda & 0 & 0 & 0 \\\\\n",
    "0 & 0 & 0 & 2\\mu & 0 & 0 \\\\\n",
    "0 & 0 & 0 & 0 & 2\\mu & 0 \\\\\n",
    "0 & 0 & 0 & 0 & 0 & 2\\mu\n",
    "\\end{bmatrix}\n",
    "\\begin{bmatrix}\n",
    "u_x \\\\ v_y \\\\ w_z \\\\ \\frac{w_y + v_z}{2} \\\\ \\frac{w_x + u_z}{2} \\\\ \\frac{v_x + w_y}{2}\n",
    "\\end{bmatrix}\\\\\n",
    "& = \\begin{bmatrix}\n",
    "2\\mu+\\lambda & \\lambda & \\lambda & 0 & 0 & 0\\\\\n",
    "\\lambda & 2\\mu+\\lambda  & \\lambda & 0 & 0 & 0\\\\\n",
    "\\lambda &  \\lambda & 2\\mu+\\lambda & 0 & 0 & 0 \\\\\n",
    "0 & 0 & 0 & \\mu & 0 & 0 \\\\\n",
    "0 & 0 & 0 & 0 & \\mu & 0 \\\\\n",
    "0 & 0 & 0 & 0 & 0 & \\mu\n",
    "\\end{bmatrix}\n",
    "\\begin{bmatrix}\n",
    "\\varepsilon_{11} \\\\ \\varepsilon_{22} \\\\ \\varepsilon_{33} \\\\ 2\\varepsilon_{23} \\\\ 2\\varepsilon_{13} \\\\ 2\\varepsilon_{12}\n",
    "\\end{bmatrix}\\\\\n",
    "&= D \\begin{bmatrix}\n",
    "\\frac{\\partial }{\\partial x} & 0 & 0\\\\\n",
    "0 & \\frac{\\partial }{\\partial y} & 0\\\\\n",
    "0 & 0 & \\frac{\\partial }{\\partial z}\\\\\n",
    "0 & \\frac{\\partial }{\\partial z} & \\frac{\\partial }{\\partial y} \\\\\n",
    "\\frac{\\partial }{\\partial z} & 0 & \\frac{\\partial }{\\partial x} \\\\\n",
    "\\frac{\\partial }{\\partial y} & \\frac{\\partial }{\\partial x} & 0\\\\\n",
    "\\end{bmatrix}\n",
    "\\begin{bmatrix}\n",
    "u \\\\ v\\\\ w\n",
    "\\end{bmatrix}\\\\\n",
    "& = D[\\partial] \n",
    "\\begin{bmatrix}\n",
    "\\lambda_1 & \\lambda_2 & \\lambda_3 & \\lambda_4 & 0 & 0  & 0 & 0 & 0 & 0 & 0 & 0 \\\\\n",
    "0 & 0 & 0 & 0 &\\lambda_1  & \\lambda_2 & \\lambda_3 & \\lambda_4 & 0  & 0 & 0  & 0 \\\\\n",
    "0 & 0  & 0 & 0  & 0 & 0 & 0 & 0 & \\lambda_1 & \\lambda_2 & \\lambda_3 & \\lambda_4\n",
    "\\end{bmatrix}\n",
    "\\begin{bmatrix}\n",
    "\\mbu_1 \\\\ \\mbu_2 \\\\ \\mbu_3 \\\\ \\mbu_4\n",
    "\\end{bmatrix}\\\\\n",
    "& = D\n",
    "\\begin{bmatrix}\n",
    "[\\partial]\\lambda_1, [\\partial]\\lambda_2, [\\partial]\\lambda_3, [\\partial]\\lambda_4]\n",
    "\\end{bmatrix}\n",
    "\\begin{bmatrix}\n",
    "\\mbu_1 \\\\ \\mbu_2 \\\\ \\mbu_3 \\\\ \\mbu_4\n",
    "\\end{bmatrix}\\\\\n",
    "\\end{align}\n",
    "$$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "$$\n",
    "\\begin{aligned}\n",
    "\\begin{bmatrix}\n",
    "\\frac{\\partial \\lambda_1 }{\\partial x} & \\frac{\\partial \\lambda_2 }{\\partial x} & \\frac{\\partial \\lambda_3 }{\\partial x} & \\frac{\\partial \\lambda_4 }{\\partial x} & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\\\\n",
    "0 & 0 & 0 & 0 & \\frac{\\partial \\lambda_1 }{\\partial y} & \\frac{\\partial \\lambda_2}{\\partial y} & \\frac{\\partial \\lambda_3}{\\partial y} & \\frac{\\partial \\lambda_4}{\\partial y} & 0  & 0  & 0  & 0\\\\\n",
    "0 & 0 & 0 & 0 &  0 & 0 & 0 & 0 & \\frac{\\partial\\lambda_1 }{\\partial z} & \\frac{\\partial\\lambda_2 }{\\partial z}& \\frac{\\partial\\lambda_3 }{\\partial z} & \\frac{\\partial\\lambda_4 }{\\partial z}\\\\\n",
    "0 & 0 & 0 & 0 & \\frac{\\partial \\lambda_1}{\\partial z} &  \\frac{\\partial \\lambda_2}{\\partial z} &  \\frac{\\partial \\lambda_3}{\\partial z} &  \\frac{\\partial \\lambda_4}{\\partial z} & \\frac{\\partial\\lambda_1 }{\\partial y}  & \\frac{\\partial\\lambda_2 }{\\partial y}  & \\frac{\\partial\\lambda_3 }{\\partial y}  & \\frac{\\partial\\lambda_4 }{\\partial y} \\\\\n",
    "\\frac{\\partial \\lambda_1}{\\partial z} & \\frac{\\partial \\lambda_2}{\\partial z} &  \\frac{\\partial \\lambda_3}{\\partial z} & \\frac{\\partial \\lambda_4}{\\partial z} & 0 & 0 & 0 & 0 & \\frac{\\partial \\lambda_1}{\\partial x} & \\frac{\\partial\\lambda_3 }{\\partial x} & \\frac{\\partial \\lambda_3 }{\\partial x} & \\frac{\\partial \\lambda_4}{\\partial x}\\\\\n",
    "\\frac{\\partial \\lambda_1}{\\partial y} & \\frac{\\partial \\lambda_2}{\\partial y} & \\frac{\\partial \\lambda_3}{\\partial y} & \\frac{\\partial \\lambda_4}{\\partial y} & \\frac{\\partial \\lambda_1}{\\partial x} & \\frac{\\partial \\lambda_2}{\\partial x} & \\frac{\\partial\\lambda_3 }{\\partial x} & \\frac{\\partial\\lambda_4 }{\\partial x} & 0 & 0 & 0 & 0\\\\\n",
    "\\end{bmatrix}\n",
    "\\end{aligned}\n",
    "$$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 线弹性问题快速算法"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "near-nullspace inclue: rigid body modes"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\"algebraically smooth error\" must be approximated well in the range of the interpolation operator."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "In particular, if $e$\n",
    " is a smooth error vector in AMG that satifies $Ae=0$ in all interior nodes, then $e$ should be interpolated exactly on the fine grid."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "nullspace of the operator is comprised only of constant vectors. "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "$$\n",
    "A_{ii}e_i + A_{iC}e_C + A_{iF}e_F = 0\n",
    "$$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "$$\n",
    "e_F = W_{FC}e_C + W_{Fi}e_i\n",
    "$$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "* $(1, 0, 0)$\n",
    "* $(0, 1, 0)$\n",
    "* $(0, 0, 1)$\n",
    "* $(-y, x, 0)$\n",
    "* $(z, 0, -x)$\n",
    "* $(0, -z, y)$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "* the unknown-based approach\n",
    "* the node-based approach"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "* a least-squares based approach\n",
    "* a global matrix approach \n",
    "* a local neighborhood approach"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "## 参考\n",
    "\n",
    "[1] http://solidmechanics.org/text/Chapter3_2/Chapter3_2.htm"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 快速算法 "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "$$\n",
    "P_0 = \n",
    "\\begin{pmatrix}\n",
    "1 & 0 & 0 & 0 & -(z_i - z_j) &  y_i - y_j \\\\\n",
    "0 & 1 & 0 & z_i - z_j & 0 & -(x_i - x_j) \\\\\n",
    "0 & 0 & 1 & -(y_i - y_j) & x_i - x_j & 0\n",
    "\\end{pmatrix}\n",
    "$$"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.2"
  },
  "latex_envs": {
   "bibliofile": "biblio.bib",
   "cite_by": "apalike",
   "current_citInitial": 1,
   "eqLabelWithNumbers": true,
   "eqNumInitial": 0
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
